home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / convert / c_conver / itox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1984-11-19  |  768 b   |  30 lines

  1. /*----- ARCHIVE itox.c -----------------------------------------------------*/
  2. /*
  3. **    itox -- converts nbr to hex string of length sz
  4. **        right adjusted and blank filled, returns str
  5. **
  6. **        if sz > 0 terminate with null byte
  7. **        if sz = 0 find end of string
  8. **        if sz < 0 use last byte for data
  9. */
  10. #define NULL    0
  11. itox(nbr,str,sz) int nbr; char str[]; int sz; {
  12.     int digit, offset;
  13.     if (sz>0) str[--sz]=NULL;
  14.     else if (sz<0) sz=-sz;
  15.     else while(str[sz]!=NULL) ++sz;
  16.     while (sz) {
  17.         digit=nbr&15; nbr=(nbr>>4)&4095;
  18.         if (digit<10) offset=48; else offset=55;
  19.         str[--sz]=digit+offset;
  20.         if (nbr==0) break;
  21.     }
  22.     while (sz) str[--sz]=' ';
  23.     return str;
  24. }
  25. to directory buffer
  26.     ;
  27. DIRBUF:    DS    ENTRIES*16    ;directory buffer
  28.     ;
  29.     END    BEGIN
  30. PA:X